local reqing = fk.CreateSkill {
  name = "cf_reqing",
}

Fk:loadTranslationTable {
  ["cf_reqing"] = "热情",
  [":cf_reqing"] = "每名角色限一次，当你使用牌指定目标后，你可以选择一项：1.摸两张牌，2.令目标角色摸三张牌。你对热情选择过的角色使用牌没有次数和距离限制。",
  ["#cf_reqing_choice1"] = "摸两张牌",
  ["#cf_reqing_choice2"] = "令%src摸三张牌",
  ["#cf_reqing_ask"] = "是否对%src发动【热情】",
  ["$cf_reqing1"] = "侦察骑士登场！",
  ["$cf_reqing2"] = "侦察骑士，发现目标！",
}

reqing:addEffect(fk.AfterCardTargetDeclared, {
  can_trigger = function(self, event, target, player, data)
    return data.from == player and player:hasSkill(reqing.name) and table.find(data.tos, function(element, index, array)
      return element:getMark(reqing.name) == 0
    end) ~= nil
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local targets = table.filter(data.tos, function(element, index, array)
      return element:getMark(reqing.name) == 0
    end)
    local room = player.room
    for _, p in ipairs(targets) do
      local choice = room:askToChoice(player, {
        choices = { "#" .. reqing.name .. "_choice1", "#" .. reqing.name .. "_choice2:" .. p.id, "取消", },
        skill_name = reqing.name,
      })
      if choice == "#" .. reqing.name .. "_choice1" then
        player:drawCards(2)
      elseif choice == "#" .. reqing.name .. "_choice2:" .. p.id then
        p:drawCards(3)
      else
        goto continue
      end
      room:addPlayerMark(p, reqing.name, 1)
      ::continue::
    end
  end,
})

reqing:addEffect("targetmod", {
  bypass_times = function(self, player, skill, scope, card, to)
    return card and to and player:hasSkill(reqing.name) and to:getMark(reqing.name) > 0
  end,
  bypass_distances = function(self, player, skill, card, to)
    return card and to and player:hasSkill(reqing.name) and to:getMark(reqing.name) > 0
  end
})

return reqing
